package android.slc.appbase.utils;

import android.slc.appbase.ui.dialog.LoadingDialogView;
import android.slc.appbase.ui.dialog.SlcPopup;

public class LoadingUtils {
    private static final String KEY_PRESENTER_DIALOG = "loadingDialog";

    public static void showLoadingDialog(String loadingMsg) {
        showLoadingDialog(KEY_PRESENTER_DIALOG, loadingMsg);
    }

    public static void showLoadingDialog(String key, String loadingMsg) {
        SlcPopup.addOperate(key, LoadingDialogView.show(loadingMsg));
        /*JFXAlert jfxAlert = new JFXAlert();
        jfxAlert.setContent(new JFXProgressBar());
        jfxAlert.setOnCloseRequest(new EventHandler<DialogEvent>() {
            @Override
            public void handle(DialogEvent event) {
                SlcPopup.removeOperate(key);
            }
        });
        jfxAlert.setOnShowing(new EventHandler<DialogEvent>() {
            @Override
            public void handle(DialogEvent event) {
                SlcPopup.addOperate(key, jfxAlert);
            }
        });
        jfxAlert.initStyle(StageStyle.UNDECORATED);
        jfxAlert.show();*/
    }

    public static void dismissLoadingDialog() {
        dismissLoadingDialog(KEY_PRESENTER_DIALOG);
    }

    public static void dismissLoadingDialog(String key) {
        SlcPopup.dismissByKey(key);
    }
}
